//2009/08/02 17:55:54
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <numeric>

using namespace std;

template<class T, class U> T cast(U x)
{
	ostringstream os;
	os << x;
	T res;
	istringstream is(os.str());
	is >> res;
	return res;
}
template<class T> vector<T> split(string s, string x=" ")
{
	vector<T> res;
	for(int i=0; i<s.size(); i++)
	{
		string a;
		while(i < s.size() && x.find(s[i])==string::npos)
			a += s[i++];
		if(!a.empty())
			res.push_back(cast<T>(a));
	}
	return res;
}

class BaseMystery
{
public:
    vector <int> getBase(string e)
    {
		vector<string> x = split<string>(e,"+=");
		vector<int> result;
		for(int i=2; i<=20; i++)
		{
			int a = convert(x[0], i);
			if(a == -1) continue;
			int b = convert(x[1], i);
			if(b == -1) continue;
			int c = convert(x[2], i);
			if(c == -1) continue;
			if(a+b == c) result.push_back(i);
		}
		return result;
    }
private:
	int convert(string s, int base)
	{
		int result = 0;
		for(int i=0; i<s.size(); i++)
		{
			int d=isdigit(s[i]) ? s[i] - '0' : s[i] - 'A' + 10;
			if(d >= base)
				return -1;
			result = result * base + d;
		}
		return result;
	}
};
